package com.mapper;

import com.pojo.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
* @author XY004
* @description 针对表【tb_user】的数据库操作Mapper
* @createDate 2024-11-18 10:01:34
* @Entity com.pojo.User
*/
public interface UserMapper {

    int deleteByPrimaryKey(Long id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    User findUserWithOrders(Integer id);

    @Select("select * from tb_user where id=#{id}")
    @Results({
            @Result(column = "username", property = "username"),
            @Result(column = "address", property = "address"),
            @Result(column = "id", property = "ordersList",
                    many = @Many(select = "com.mapper.TbOrdersMapper.selectOrdersByUserId"))
    })
    User selectUserById(int id);

}
